/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.smitala.gephi.communitydetection.linkcommunities;

import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import org.openide.util.Exceptions;
import sk.smitala.gephi.communitydetection.utils.CommonUtils;

/**
 *
 * @author smitalm
 */
public class LinkClustererPanel extends javax.swing.JPanel {

    /**
     * Creates new form LinkClustererPanel
     */
    public LinkClustererPanel() {
	initComponents();
	setLinkButton();
    }

    private void setLinkButton() {
	final URI uri;
	try {
	    uri = new URI("http://arxiv.org/pdf/0903.3178v3.pdf");
	} catch (URISyntaxException ex) {
	    Exceptions.printStackTrace(ex);
	    linkButton.setEnabled(false);
	    return;
	}
	linkButton.setToolTipText(uri.toString());
	linkButton.addMouseListener(new MouseListener() {
	    @Override
	    public void mouseClicked(MouseEvent e) {
		CommonUtils.open(uri);
	    }

	    @Override
	    public void mousePressed(MouseEvent e) {
	    }

	    @Override
	    public void mouseReleased(MouseEvent e) {
	    }

	    @Override
	    public void mouseEntered(MouseEvent e) {
	    }

	    @Override
	    public void mouseExited(MouseEvent e) {
	    }
	});
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        header = new org.jdesktop.swingx.JXHeader();
        linkButton = new javax.swing.JLabel();

        header.setDescription(org.openide.util.NbBundle.getMessage(LinkClustererPanel.class, "LinkClustererPanel.header.description")); // NOI18N
        header.setTitle(org.openide.util.NbBundle.getMessage(LinkClustererPanel.class, "LinkClustererPanel.header.title")); // NOI18N

        org.openide.awt.Mnemonics.setLocalizedText(linkButton, org.openide.util.NbBundle.getMessage(LinkClustererPanel.class, "LinkClustererPanel.linkButton.text")); // NOI18N
        linkButton.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(header, javax.swing.GroupLayout.DEFAULT_SIZE, 529, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(linkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(header, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(linkButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXHeader header;
    private javax.swing.JLabel linkButton;
    // End of variables declaration//GEN-END:variables
}
